import 'package:flutter/cupertino.dart';
import 'package:glassmorphism/glassmorphism.dart';

///玻璃态小组件

class GlassWidget extends StatefulWidget{

  final double width;
  final double height;
  final double borderRadius;
  final double blur;
  final double linearGradientBeginOpacity;
  final double linearGradientEndOpacity;
  final double borderGradientBeginOpacity;
  final double borderGradientEndOpacity;
  final Widget child;
  final Color color;


   GlassWidget({
    required this.width, required this.height,required this.borderRadius,required this.blur,required this.linearGradientBeginOpacity,required this.linearGradientEndOpacity,required this.borderGradientBeginOpacity,required this.borderGradientEndOpacity,required this.child,required this.color
  });

  @override
  _GlassWidget createState()=> _GlassWidget();
}

class _GlassWidget extends State<GlassWidget>{


  @override
  Widget build(BuildContext context) {
    return GlassmorphicContainer(
        alignment: Alignment.bottomCenter,
        width: widget.width,
        height: widget.height,
        borderRadius: widget.borderRadius,
        border: 2,
        blur: widget.blur,
        linearGradient: LinearGradient(
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
          colors: <Color>[
            widget.color.withOpacity(widget.linearGradientBeginOpacity),
            widget.color.withOpacity(widget.linearGradientEndOpacity)
          ],
          stops: [
            0.1,
            1
          ]
        ),
        borderGradient: LinearGradient(
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
            colors: <Color>[
              widget.color.withOpacity(widget.borderGradientBeginOpacity),
              widget.color.withOpacity(widget.borderGradientEndOpacity)
            ]
        ),
      child: widget.child,


    );
  }

}
